import request from "../../utils/request"

// pages/YQ/YQ.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        YQ_User:"",
        YQ_Phone:"",
        YQ_Time:"",
        YQ_Something:"",
        YQ_CarNumber:""

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    getUser(e){
        console.log(e.detail.value)
        this.setData({
            YQ_User:e.detail.value
        })
    },
    getPhone(e){
        console.log(e.detail.value)
        this.setData({
            YQ_Phone:e.detail.value
        })
    },
    getTime(e){
        console.log(e.detail.value)
        this.setData({
            YQ_Time:e.detail.value
        })
    },
    getSomething(e){
        console.log(e.detail.value)
        this.setData({
            YQ_Something:e.detail.value
        })
    },
    getCarNumber(e){
        console.log(e.detail.value)
        this.setData({
            YQ_CarNumber:e.detail.value
        })
    },
    YQ_post(){
        if(this.data.YQ_User.length===0||this.data.YQ_Phone.length===0||this.data.YQ_Time.length===0||this.data.YQ_Something.length===0||this.data.YQ_CarNumber.length===0){
            console.log("数据不能为空！")
        }else{
            request({
                url:"/YQ",
                method:"post",
                data:{
                    user:wx.getStorageSync('Token')[0].Name,
                    tel:wx.getStorageSync('Token')[0].tel,
                    YQ_User:this.data.YQ_User,
                    YQ_Phone:this.data.YQ_Phone,
                    YQ_Time:this.data.YQ_Time,
                    YQ_Something:this.data.YQ_Something,
                    YQ_CarNumber:this.data.YQ_CarNumber,
                    YQ_Status:0
                },
            }).then(res=>{
                console.log(res)
                console.log("提交成功！")
                wx.navigateBack({
                  delta: 1,
                })
            })
        }
    }


})